package com.fin.zw.aiqas.util;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URI;

public class MyWebSocketClient extends WebSocketClient {

    private final static Logger logger = LoggerFactory.getLogger(MyWebSocketClient.class);

    public MyWebSocketClient(String url) {
        super(URI.create(url));
    }

    @Override
    public void onOpen(ServerHandshake serverHandshake) {
        logger.info("创建一个链接........");
    }

    @Override
    public void onMessage(String s) {
        logger.info("接受服务端的信息：" + s);
    }

    @Override
    public void onClose(int i, String s, boolean b) {
        logger.info("关闭链接........");
    }

    @Override
    public void onError(Exception e) {
        logger.info("连接异常......");
    }
}
